package com.hitqz.robot.biz.controller;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hitqz.robot.api.business.entity.CvdStoveEntity;
import com.hitqz.robot.api.business.dto.CvdStoveQueryDTO;
import com.hitqz.robot.api.business.dto.CvdStoveSaveDTO;
import com.hitqz.robot.api.business.dto.CvdStoveUpdateDTO;
import com.hitqz.robot.api.business.vo.CvdStoveVO;
import com.hitqz.robot.biz.service.CvdStoveService;
import com.hitqz.robot.common.core.util.HitConvertUtils;
import com.hitqz.robot.common.core.util.R;
import com.hitqz.robot.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * CVD炉子管理
 *
 * @author kehanjiang
 * @date 2025-09-19 10:48:41
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/cvdStove")
@Tag(description = "cvdStove", name = "CVD炉子管理管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CvdStoveController {

    private final CvdStoveService cvdStoveService;

    /**
     * 分页查询
     *
     * @param page 分页对象
     * @param dto  CVD炉子管理
     * @return
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page")
    public R<Page<CvdStoveVO>> getCvdStovePage(@ParameterObject Page page, @ParameterObject CvdStoveQueryDTO dto) {
        dto = HitConvertUtils.emptyToNull(dto);
        return R.ok(cvdStoveService.getCvdStovePage(page, dto));
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/list")
    public List<CvdStoveEntity> getCvdStoveList() {
        return cvdStoveService.list();
    }

    /**
     * 通过id查询CVD炉子管理
     *
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<CvdStoveVO> getById(@PathVariable("id") Long id) {
        return R.ok(cvdStoveService.getCvdStoveById(id));
    }

    /**
     * 新增CVD炉子管理
     *
     * @param dto CVD炉子管理
     * @return R
     */
    @Operation(summary = "新增CVD炉子管理", description = "新增CVD炉子管理")
    @SysLog("新增CVD炉子管理")
    @PostMapping
    public R<Boolean> save(@RequestBody CvdStoveSaveDTO dto) {
        return R.ok(cvdStoveService.saveCvdStove(dto));
    }

    /**
     * 修改CVD炉子管理
     *
     * @param dto CVD炉子管理
     * @return R
     */
    @Operation(summary = "修改CVD炉子管理", description = "修改CVD炉子管理")
    @SysLog("修改CVD炉子管理")
    @PutMapping
    public R<Boolean> updateById(@RequestBody CvdStoveUpdateDTO dto) {
        return R.ok(cvdStoveService.updateCvdStoveById(dto));
    }

    /**
     * 通过id删除CVD炉子管理
     *
     * @param ids id列表
     * @return R
     */
    @Operation(summary = "通过id删除CVD炉子管理", description = "通过id删除CVD炉子管理")
    @SysLog("通过id删除CVD炉子管理")
    @DeleteMapping
    public R<Boolean> removeById(@RequestBody Long[] ids) {
        return R.ok(cvdStoveService.removeCvdStoveBatchByIds(CollUtil.toList(ids)));
    }


}